﻿#region 命名空间

using System;
using WinnerCMS.Common;
using WinnerCMS.BLL;
using WinnerCMS.Model.Attribute;
using WinnerCMS.Model.Enum;
using WinnerCMS.WebFactory;

#endregion

namespace WinnerCMS.WebUI.Admin.Category
{
    [Access("256003")]
    public partial class Merge : PageBase
    {
        private readonly CategoryManage _myBLL = new CategoryManage();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Bind();
            }
        }

        private void Bind()
        {
            this._myBLL.BindDDL(this.ddlOldCategory, BindOption.NoLink, "<请选择>", null);
            this._myBLL.BindDDL(this.ddlNewCategory, BindOption.NoLink, "<请选择>", null);
        }

        protected void cbkChildCategory_CheckedChanged(object sender, EventArgs e)
        {
            this.cbkDeleteCategory.Enabled = this.cbkChildCategory.Checked;
            this.cbkDeleteCategory.Checked = this.cbkChildCategory.Checked;
        }

        protected void btnMerge_Click(object sender, EventArgs e)
        {
            var resu = this._myBLL.MergeCategory(int.Parse(this.ddlOldCategory.SelectedValue),
                int.Parse(this.ddlNewCategory.SelectedValue), this.cbkChildCategory.Checked,
                this.cbkDeleteCategory.Checked);

            if (string.IsNullOrEmpty(resu.Errors))
            {
                Bind();
                MsgBox.Message("操作成功！", this);
            }
            else
            {
                MsgBox.Message(resu.Errors, this);
            }
        }
    }
}